﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DataAccess;

namespace QUANLYKHACHSAN_N4
{
    public partial class frmChiTietHoaDon : Form
    {
        string maphong, maphieuthue, khachhang, maloai;
        public frmChiTietHoaDon(string maphong, string maphieuthue, string khachhang, string maloai, double ngaythang)
        {
            InitializeComponent();
            this.maphieuthue = maphieuthue;
            this.maphong = maphong;
            this.khachhang = khachhang; this.maloai = maloai;
            label7.Text = ngaythang.ToString();
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label6_TextChanged(object sender, EventArgs e)
        {
            decimal gia = decimal.Parse(label6.Text);
            decimal songay = decimal.Parse(label7.Text);
            label8.Text = (gia * songay).ToString();
        }
        void GetThanhTien()
        {
            foreach (DataGridViewRow r in dataGridViewX1.Rows)
            {
                try
                {
                    int soluong = int.Parse(r.Cells["soluong"].Value.ToString());
                    decimal gia = decimal.Parse(r.Cells["dongia"].Value.ToString());
                    r.Cells["ttien"].Value = soluong * gia;
                }
                catch (Exception)
                {

                }
            }
        }
        decimal tongtien()
        {
            decimal thanhtien = 0;
            foreach (DataGridViewRow r in dataGridViewX1.Rows)
            {
                //thanhtien += decimal.Parse(r.Cells["ttien"].Value.ToString());
            }
            return thanhtien;
        }

        private void frmChiTietHoaDon_Load(object sender, EventArgs e)
        {
            label10.Text = khachhang;
            LoaiPhong_Info lp = LoaiPhong_Info.GetByID(maloai);
            label6.Text = lp.gia.ToString();
            label9.Text = maphong;
            dataGridViewX1.DataSource = DichVu_Info.GetAll(maphieuthue).Tables[0];
            GetThanhTien();
            label12.Text = tongtien().ToString();
        }
    }
}
